home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / bipl.zip / PROGS.ZIP / ROFFCMDS.ICN < prev    next >
Text File  |  1992-11-26  |  2KB  |  56 lines

  1. ############################################################################
  2. #
  3. #    File:     roffcmds.icn
  4. #
  5. #    Subject:  Program to list roff commands and macros
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     June 10, 1988
  10. #
  11. ###########################################################################
  12. #  
  13. #     This progam processes standard input and writes a tabulation of
  14. #  nroff/troff commands and defined strings to standard output.
  15. #  
  16. #  Limitations:
  17. #  
  18. #     This program only recognizes commands that appear at the beginning of
  19. #  lines and does not attempt to unravel conditional constructions.
  20. #  Similarly, defined strings buried in disguised form in definitions are
  21. #  not recognized.
  22. #  
  23. #  Reference:
  24. #  
  25. #     Nroff/Troff User's Manual, Joseph F. Ossana, Bell Laboratories,
  26. #  Murray Hill, New Jersey. October 11, 1976.
  27. #  
  28. ############################################################################
  29.  
  30. procedure main()
  31.    local line, con, mac, y, nonpuncs, i, inname, infile, outname, outfile
  32.  
  33.    nonpuncs := ~'. \t\\'
  34.  
  35.    con := table(0)
  36.    mac := table(0)
  37.    while line := read() do {
  38.       line ? if tab(any('.\'')) then
  39.          con[tab(any(nonpuncs)) || (tab(upto(' ') | 0))] +:= 1
  40.       line ? while tab((i := find("\\")) + 1) do {
  41.       case move(1) of {
  42.       "(":   move(2)
  43.       "*" | "f" | "n":  if ="(" then move(2) else move(1)
  44.       }
  45.       mac[&subject[i:&pos]] +:= 1
  46.       }
  47.    }
  48.    con := sort(con,3)
  49.    write(,"Commands:\n")
  50.    while write(,get(con),"\t",get(con))
  51.    mac := sort(mac,3)
  52.    write(,"\nControls:\n")
  53.    while write(,get(mac),"\t",get(mac))
  54.  
  55. end
  56.